fix: patch fypp to emit resync linemarker after single-line $: calls#1436
Conversation
Single-line $:GPU_PARALLEL_LOOP() and similar macros expand to leaving the next Fortran statement attributed to the macro call-site line rather than the following source line. This causes off-by-1 errors in all backtraces, compiler error messages, and debugger line info for every GPU-macro-wrapped loop body in the codebase (~2188 affected call sites). Root cause: fypp's _postprocess_eval_line only emits a trailing resync linemarker when the $: call spans >1 source lines (multiline) or when line-folding splits output (unsync). Single-line calls that produce multi-line output hit neither condition. Fix: always emit the resync marker after any $: call that ends its line. Implemented as a patch applied to the installed fypp.py after venv setup in toolchain/bootstrap/python.sh, with a sentinel check so it is idempotent across reinstalls.
f57c3ef to
b1edca0
Compare
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
Claude Code ReviewHead SHA: b1edca0 Files changed:
Findings
The already-applied check uses: if ! grep -q "or True" "$FYPP_PY" 2>/dev/null; then
The patch itself adds a distinctive comment that is virtually guaranteed to be unique: # Always emit a resync marker after a $: call. Without this,Using that string as the sentinel is far more robust: if ! grep -q "Always emit a resync marker" "$FYPP_PY" 2>/dev/null; then |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1436 +/- ##
=======================================
Coverage 65.00% 65.00%
=======================================
Files 72 72
Lines 18810 18810
Branches 1553 1553
=======================================
Hits 12227 12227
Misses 5615 5615
Partials 968 968 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Referencing #1435
Problem
fypp's_postprocess_eval_lineonly emitted a trailing resync linemarkerwhen the output was multi-line or continuation lines were out of sync. For
single-line
$:/@:/ inline#{...}#calls this condition was nevertrue, so no resync was written.
When a macro expanded by such a call contains
#ifdef/#endifblocks,downstream Fortran preprocessors (
gfortran -cpp,flang) skip the contentof never-taken branches but still advance their internal line counter over
those physical lines. Without a resync marker after the expansion, every
subsequent source line is attributed to the wrong location — producing
misleading compile-time diagnostics and incorrect debugger line info.
Changes
toolchain/patches/fypp-linemarker-resync.patch+toolchain/bootstrap/python.shApplies a patch to fypp at build time that unconditionally emits the resync
marker after every eval directive. An upstream fix has been submitted:
aradi/fypp#66. Once that is released,
this patch and its application in
python.shcan be removed (tracked in #1435)..fppsource changesSeveral source files had long Fortran continuation lines that crossed fypp
macro-expansion boundaries in a way that triggered the bug. These are reformatted
so that each continuation segment is self-contained, fixing the immediate
symptom regardless of fypp version.
Draft status
Marked as draft pending review of the source reformats and CI results. Will be
ready to merge once CI passes; the patch can be dropped in a follow-up once
aradi/fypp#66 is tagged in a release.